package com.topisv.tms.task;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.topisv.tms.entity.EdiOrder;
import com.topisv.tms.entity.ediOrder.EdiOrderVO;
import com.topisv.tms.service.EdiOrderService;

public class EdiOrderOutScope implements Runnable {

	private Logger logger = LoggerFactory.getLogger(getClass());
	private BlockingQueue<EdiOrderVO> tasks;
	private EdiOrderService ediOrderService;
	
	public EdiOrderOutScope(BlockingQueue<EdiOrderVO> tasks,EdiOrderService ediOrderService) {
		this.tasks = tasks;
		this.ediOrderService = ediOrderService;
	}
	
	@Override
	public void run() {
		try {
			while (true) {
				EdiOrderVO ediOrder = null;
				ediOrder = tasks.take();
				if (ediOrder != null) {
					ediOrderService.filterOutScope(ediOrder);
				}
			}
		} catch (Exception e) {
			logger.error("", e);
		}
	}
	
	@Override
	protected void finalize() throws Throwable {
		Thread.sleep(500);
		super.finalize();
	}
}
